package com.liangdemo.web.test.demo;

import java.util.ArrayList;
import java.util.List;

/**
 * 演示堆内存溢出
 *
 * @author Mr.Liang
 * @date 2022/5/18 17:51
 */

public class Demo2 {
    public static void main(String[] args) {
        int count = 0;
        try {
            List<String> list = new ArrayList<>();
            String a = "hello";
            while (true) {
                list.add(a);
                a = a + a;
                count++;
            }
        } catch (Throwable e) {
            e.printStackTrace();
            System.out.println(count);
        }

    }
}
